﻿<Window x:Class="CncConvProg.View.Dialog.MachinesDialogView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Resources="clr-namespace:MecPrev.Resources;assembly=MecPrev.Resources" 
        Title="{x:Static Resources:GuiRes.dlgMachine}" MinHeight="300" MinWidth="600"
        WindowStyle="ToolWindow"
        WindowState="Normal"
        Width="600"
        Height="400"
        WindowStartupLocation="CenterScreen"
        >
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="671*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.362*" MinWidth="150" />
            <ColumnDefinition Width="0.638*" MinWidth="150" />
        </Grid.ColumnDefinitions>

        <!-- Lista Utensili -->
        <Border x:Name="Colonna_SX" Grid.RowSpan="1">
            <DockPanel>
                <Menu DockPanel.Dock="Top" HorizontalAlignment="Left">
                    <MenuItem Header="{x:Static Resources:GuiRes.AddMachine}"  >
                        <MenuItem Header="{x:Static Resources:GuiRes.VerticalMill}" Command="{Binding AddMachineCmd}"  CommandParameter="0"/>
                        <MenuItem Header="{x:Static Resources:GuiRes.Lathe2Ax}" Command="{Binding AddMachineCmd}"  CommandParameter="1"/>
                        <MenuItem Header="{x:Static Resources:GuiRes.Lathe3Ax}" Command="{Binding AddMachineCmd}"  CommandParameter="2"/>
                    </MenuItem>
                </Menu>
                <ListView ItemsSource="{Binding Path=Machines}" SelectionMode="Single" 
                          SelectedItem="{Binding Path=SelectedMachine}" Margin="5"
                          >
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Header="{x:Static Resources:GuiRes.Name}" DisplayMemberBinding="{Binding Path=MachineName}" Width="130"/>
                            <GridViewColumn Width="50">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="X" 
                                        Command="{Binding DataContext.DelMachineCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Window}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"
                                                />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>
            </DockPanel>
        </Border>

        <GridSplitter Width="2" Height="250"  />
        <!-- Dettagli Utensile -->
        <Border x:Name="Colonna_DX" Grid.Column="1" Margin="2,5,5,5" BorderThickness="2" Grid.RowSpan="1" DataContext="{Binding Path=SelectedMachine}">
            <DockPanel>

                <TextBlock HorizontalAlignment="Left" DockPanel.Dock="Top"
                               Width="250" Text="{Binding Path=MachineName}" FontSize="24" Margin="10,10,0,10" />
                <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
                    <TextBlock Text="{x:Static Resources:GuiRes.MachineName}" MinWidth="100" />
                    <TextBox Text="{Binding Path=MachineName}" MinWidth="100"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
                    <TextBlock Text="{x:Static Resources:GuiRes.MaxRev}" MinWidth="100" />
                    <TextBox Text="{Binding Path=MaxGiri}" MinWidth="100"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
                    <TextBlock Text="{x:Static Resources:GuiRes.RapidVel}" MinWidth="100" />
                    <TextBox Text="{Binding Path=VelocitaRapido}" MinWidth="100"/>
                </StackPanel>

                <GroupBox DockPanel.Dock="Top" Header="{x:Static Resources:GuiRes.DefaultTimeGroup}" Margin="3,10,3,0" Padding="5">
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{x:Static Resources:GuiRes.HourlyCost}" MinWidth="170" />
                            <TextBox Text="{Binding Path=CostoOrarioMacchina, StringFormat=\{0:c\}}" MinWidth="80" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{x:Static Resources:GuiRes.SetupFixtureTime}" MinWidth="170" />
                            <TextBox Text="{Binding Path=TempoSetupFixture}" MinWidth="80" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{x:Static Resources:GuiRes.SetupToolTime}" MinWidth="170" />
                            <TextBox Text="{Binding Path=TempoSetupTool}" MinWidth="80" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{x:Static Resources:GuiRes.ProgrammingOperationTime}" MinWidth="170" />
                            <TextBox Text="{Binding Path=TempoProgrammazioneOperazione}" MinWidth="80" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{x:Static Resources:GuiRes.LoadingMachine}" MinWidth="170" />
                            <TextBox Text="{Binding Path=TempoCaricamentoMacchina}" MinWidth="80" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{x:Static Resources:GuiRes.ChangeToolTime}" MinWidth="170" />
                            <TextBox Text="{Binding Path=ChangeToolTime}" MinWidth="80" />
                        </StackPanel>
                    </StackPanel>
                </GroupBox>
            </DockPanel>
        </Border>

        <StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Right" Grid.ColumnSpan="2" >
            <Button Content="{x:Static Resources:GuiRes.ButtonCancel}" Width="100" Margin="5" Click="Button_Click_1" />
            <Button Content="Ok" Width="100" Margin="5" Click="Button_Click" />
        </StackPanel>
    </Grid>
</Window>
